| Server IP : 121.121.20.254 / Your IP : 216.73.216.133 Web Server : Microsoft-IIS/10.0 System : Windows NT WEB-SERVER 10.0 build 20348 (Windows Server 2022) AMD64 User : IUSR ( 0) PHP Version : 8.3.28 Disable Function : NONE MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/Program Files/LibreOffice/help/en-US/text/sbasic/shared/ |
Upload File : |
<!DOCTYPE html>
<html lang="en-US" dir="ltr">
<head>
<base href="../../../../">
<noscript><meta http-equiv="refresh" content="0; URL=../../../../en-US/noscript.html"></noscript>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>CreateUnoValue Function</title>
<link rel="shortcut icon" href="media/navigation/favicon.ico">
<link type="text/css" href="normalize.css" rel="Stylesheet">
<link type="text/css" href="prism.css" rel="Stylesheet">
<link type="text/css" href="default.css" rel="Stylesheet">
<script type="text/javascript" src="polyfills.js"></script><script type="text/javascript" src="languages.js"></script><script type="text/javascript" src="en-US/langnames.js"></script><script type="text/javascript" src="flexsearch.debug.js"></script><script type="text/javascript" src="prism.js"></script><script type="text/javascript" src="help2.js" defer></script><script type="text/javascript" src="a11y-toggle.js" defer></script><script type="text/javascript" src="paginathing.js" defer></script><script type="text/javascript" src="en-US/bookmarks.js" defer></script><script type="text/javascript" src="en-US/contents.js" defer></script><script type="text/javascript" src="help.js" defer></script><meta name="viewport" content="width=device-width,initial-scale=1">
</head>
<body>
<header id="TopLeftHeader"><a class="symbol" href="en-US/text/shared/05/new_help.html"><div></div></a><a class="logo" href="en-US/text/shared/05/new_help.html"><p dir="auto">LibreOffice 24.2 Help</p></a><div class="dropdowns"><div class="modules">
<button type="button" data-a11y-toggle="modules-nav" id="modules" aria-haspopup="true" aria-expanded="false" aria-controls="modules-nav">Module</button><nav id="modules-nav" hidden=""></nav>
</div></div></header><aside class="leftside"><input id="accordion-1" name="accordion-menu" type="checkbox"><label for="accordion-1" dir="auto">Contents</label><div id="Contents" class="contents-treeview"></div></aside><div id="SearchFrame"><div id="Bookmarks">
<input id="search-bar" type="search" class="search" placeholder="Search in bookmarks for chosen module" dir="auto"><div class="nav-container" tabindex="0"><nav class="index" dir="auto"></nav></div>
</div></div>
<div id="DisplayArea" itemprop="softwareHelp" itemscope="true" itemtype="http://schema.org/SoftwareApplication">
<a name="createunovalue"></a>
<a name="bm_id3150682"></a><meta itemprop="keywords" content="CreateUnoValue function">
<h1 id="hd_id3150682" dir="auto">CreateUnoValue Function</h1>
<p id="par_id3147291" class="paragraph" dir="auto">Returns an object that represents a strictly typed value referring to the Uno type system. </p>
<p id="par_id3143267" class="paragraph" dir="auto">This object is automatically converted to an <span class="literal">Any</span> of the corresponding type when passed to Uno. The type must be specified by its fully qualified Uno type name.</p>
<div class="note">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/note.svg" alt="Note Icon
" style="width:40px;height:40px;"></div>
<div class="notetext"><p dir="auto">The LibreOffice API frequently uses the <span class="literal">Any</span> type. It is the counterpart of the <span class="literal">Variant</span> type known from other environments. The <span class="literal">Any</span> type holds one arbitrary Uno type and is used in generic Uno interfaces.</p></div>
</div>
<br>
<div class="embedded">
<a name="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Syntax:</h3>
</div>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
CreateUnoValue(Type As String, Value As Object) As Object
</code></pre></div>
<div class="embedded">
<a name="functvalue"></a>
<h3 id="hd_id061420171139087480" dir="auto">Return value:</h3>
</div>
<p id="par_id851677925987795" class="paragraph" dir="auto">Object</p>
<div class="embedded">
<a name="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parameters:</h3>
</div>
<p id="par_id561677933999834" class="paragraph" dir="auto"> <span class="emph">Type</span>: The fully qualified Uno type name. Supported data types are <span class="literal">void</span>, <span class="literal">char</span>, <span class="literal">boolean</span>, <span class="literal">byte</span>, <span class="literal">short</span>, <span class="literal">unsigned short</span>, <span class="literal">long</span>, <span class="literal">unsigned long</span>, <span class="literal">hyper</span>, <span class="literal">unsigned hyper</span>, <span class="literal">float</span>, <span class="literal">double</span>, <span class="literal">string</span>, <span class="literal">type</span>, and <span class="literal">any</span>. Names are case sensitive and may be preceded by square brackets to indicate an array.</p>
<p id="par_id521677934011767" class="paragraph" dir="auto"> <span class="emph">Value</span>: A strictly typed value.</p>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
byte_sequence_object = CreateUnoValue("[]byte", Array(85, 3, 27))
</code></pre></div>
<div class="embedded">
<a name="errorcode"></a>
<h3 id="hd_id3152869" dir="auto">Error codes:</h3>
</div>
<p id="par_id3150541" class="paragraph" dir="auto">If <span class="literal">CreateUnoValue</span> cannot convert the value to the specified Uno type, an error occurs. The <span class="literal">com.sun.star.script.Converter</span> service is responsible for the conversion.</p>
<div class="embedded">
<a name="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Example:</h3>
</div>
<p id="par_id3153524" class="paragraph" dir="auto">This function is intended for use in situations where the default Basic to Uno type converting mechanism is insufficient. This happens calling generic <span class="literal">Any</span> based API methods, such as <a target="_blank" href="https://api.libreoffice.org/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1beans_1_1XPropertySet.html">com.sun.star.beans.XPropertySet</a><span class="literal">.setPropertyValue()</span> or <a target="_blank" href="https://api.libreoffice.org/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1container_1_1XNameContainer.html">com.sun.star.container.XNameContainer</a><span class="literal">.insertByName()</span>. <span class="literal">CreateUnoValue()</span> sets a value object for the unknown Uno type.</p>
<p id="par_id511677928924995" class="paragraph" dir="auto">This example uses <a target="_blank" href="https://api.libreoffice.org/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1beans_1_1XPropertySet.html">com.sun.star.beans.XPropertySet</a><span class="literal">.addProperty()</span> method to create a document property whose default values requires <span class="literal">CreateUnoValue()</span> usage:</p>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
With ThisComponent.DocumentProperties.getUserDefinedProperties()
.addProperty("FOO", com.sun.star.beans.PropertyAttribute.REMOVEABLE, CreateUnoValue("double", 23))
End With
</code></pre></div>
<p id="par_id3150769" class="paragraph" dir="auto">You can also use this function to pass non-Any values, but this is not recommended. If Basic already knows the target type, using the <span class="literal">CreateUnoValue()</span> function will only lead to additional converting operations that slow down the Basic execution.</p>
</div>
<div id="DonationFrame"></div>
<footer><div id="DEBUG" class="debug">
<h3 class="bug">Help content debug info:</h3>
<p dir="auto">This page is: <a href="https://opengrok.libreoffice.org/xref/help/source/text/sbasic/shared/03132300.xhp" target="_blank">/text/sbasic/shared/03132300.xhp</a></p>
<p dir="auto">Title is: CreateUnoValue Function</p>
<p id="bm_module" dir="auto"></p>
<p id="bm_system" dir="auto"></p>
<p id="bm_HID" dir="auto"></p>
</div></footer>
</body>
</html>